package com.ruoyi.web.controller.system.api.cc;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.interceptor.Authentication;
import com.ruoyi.system.api.ResponseWithData;
import com.ruoyi.system.api.service.ReportPreviewService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 报告预览
 *
 * @ClassName ReportPreviewController.java
 * @date 2020/4/15 1:32 下午
 * @author yzg
 */
@Api(tags="报告预览")
@RestController
@RequestMapping("/api/cc/report/preview/")
public class ReportPreviewController extends BaseController {

    @Autowired
    private ReportPreviewService reportPreviewService;

    private static final Logger log = LoggerFactory.getLogger(ReportPreviewController.class);
    /**
     *  现场服务报告预览
     *
     * @param reportGuid
     * @param serviceNo
     * @param enginnerId
     * @return com.ruoyi.system.api.ResponseWithData
     * @author yzg
     * @date 2020/4/15 1:40 下午
     */
    @GetMapping("fieldServiceReport")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "现场服务报告预览", httpMethod = "GET", notes = "现场服务报告预览")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "报告id", name = "reportGuid", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(value = "服务单号", name = "serviceNo", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(value = "工程师ID", name = "enginnerId", required = true, dataType = "Long", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData fieldServiceReport(@RequestParam("reportGuid") String reportGuid, @RequestParam("serviceNo") String serviceNo, @RequestParam("enginnerId") String enginnerId) {
        try {
            return reportPreviewService.fieldServiceReport(reportGuid, serviceNo, enginnerId);
        } catch (Exception e) {
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }

    /**
     *  安装质量报告预览
     *
     * @param reportGuid
     * @param serviceNo
     * @param enginnerId
     * @return com.ruoyi.system.api.ResponseWithData
     * @author yzg
     * @date 2020/4/15 1:40 下午
     */
    @GetMapping("installationQualityReport")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "安装质量报告预览", httpMethod = "GET", notes = "安装质量报告预览")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "报告id", name = "reportGuid", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(value = "服务单号", name = "serviceNo", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(value = "工程师ID", name = "enginnerId", required = true, dataType = "Long", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData installationQualityReport(@RequestParam("reportGuid") String reportGuid, @RequestParam("serviceNo") String serviceNo, @RequestParam("enginnerId") String enginnerId) {
        try {
            return reportPreviewService.installationQualityReport(reportGuid, serviceNo, enginnerId);
        } catch (Exception e) {
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }

    /**
     *  验收报告预览
     *
     * @param reportGuid
     * @param serviceNo
     * @param enginnerId
     * @return com.ruoyi.system.api.ResponseWithData
     * @author yzg
     * @date 2020/4/15 1:40 下午
     */
    @GetMapping("inspectionReport")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "验收报告预览", httpMethod = "GET", notes = "验收报告预览")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "报告id", name = "reportGuid", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(value = "服务单号", name = "serviceNo", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(value = "工程师ID", name = "enginnerId", required = true, dataType = "Long", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData inspectionReport(@RequestParam("reportGuid") String reportGuid, @RequestParam("serviceNo") String serviceNo, @RequestParam("enginnerId") String enginnerId) {
        try {
            return reportPreviewService.inspectionReport(reportGuid, serviceNo, enginnerId);
        } catch (Exception e) {
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }



}
